﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>月度出勤统计查询</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../static/css/font.css">
    <link rel="stylesheet" href="../../../static/css/weadmin.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <div class="weadmin-nav">
        <span class="layui-breadcrumb" style="visibility: visible;">
            <a href="#">首页</a><span lay-separator="">/</span>
            <a href="#">考试结果查询</a><span lay-separator="">/</span>
            <a><cite>月度出勤统计查询</cite></a>
        </span>
        <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">&#x1002;</i>
        </a>
    </div>
    <div class="weadmin-body">
        <div class="layui-row">
            出勤查询：月份
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="AttendanceDateTime" placeholder="yyyy-MM">
            </div>     
            用户名：
            <div class="layui-inline">
                <input type="text" id="UserID" placeholder="用户名" autocomplete="off" class="layui-input">
            </div>
            <button class="layui-btn" id="search"><i class="layui-icon">&#xe615;</i></button>
        </div>
        <table id="datalist" lay-filter="datalist"></table>
    </div>
    <script src="../../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/html" id="tool">
        <a class="layui-btn layui-btn-xs" lay-event="detail">详细查看</a>
    </script>
    <script>
        layui.use(['table', 'jquery', 'laydate', 'layer'], function () {
            var table = layui.table,
                $ = layui.jquery,
                laydate = layui.laydate,
                layer = layui.layer;
            $.support.cors = true;
            //执行一个laydate实例
            laydate.render({
                elem: '#AttendanceDateTime',
                type: 'month',
                value: new Date()
                //, isInitValue: true
            });
            
            $.ajaxSetup({
                cache: false,
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
            })
            function showList() {
                //var swhere = JSON.stringify({ EmpName: $("#sEmpName").val().trim() });
                var swhere = "",
                    UserID = $("#UserID").val().trim(),
                    AttendanceDateTime = $("#AttendanceDateTime").val();
                if (UserID != "") { swhere += " and T1.UserID='" + UserID + "' " }
                if (AttendanceDateTime != "") { swhere += " and AttendanceDateTime LIKE '" + AttendanceDateTime + "%' " }

                table.render({
                    id: "datalist",
                    elem: '#datalist',
                    url: ApiUrl + 'AttendanceInfo/AttendanceInfoSummary', //数据接口,
                    where: { swhere: swhere },
                    cellMinWidth: 80,
                    cols: [
                        [
                            //{ type: 'checkbox' },
                            { field: 'UserID', title: '用户编号 ' ,width:180 },
                            { field: 'UserName', title: '用户名称', width: 180 },
                            { field: 'Total', title: '出勤次数', width: 180},
                            { fixed: 'right', title: '操作', align: 'center', toolbar: '#tool', width: 200 }
                        ]
                    ],
                    parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    defaultToolbar:[],
                    page: true
                });
            }
            //监听工具条
            table.on('tool(datalist)', function (obj) {
                var trdata = obj.data;
                var layEvent = obj.event;
                if (layEvent === 'detail') {
                    var detail = layer.open({
                        type: 2,
                        title: "考试详情",
                        area: ['800px', '100%'],
                        fixed: false,
                        maxmin: true,
                        content: './attendance_detail.html?UserID=' + trdata.UserID + '&AttendanceDateTime=' + $("#AttendanceDateTime").val(),
                    });
                    layer.full(detail);
                }
            });
            $(function () {
                showList();
                $("#search").click(function () {
                    showList();
                })
            })
        });
    </script>
</body>
</html>